﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

using System.Collections;
using System.Collections.Generic;
using Slam.Configuration;
using Microsoft.SharePoint;

namespace Slam.SharePoint
{
	/// <summary>
	/// Defines SLAM-specific extension methods for SPListItem with variant implementations.
	/// </summary>
	public interface IListItemExtensions
	{
		/// <summary>
		/// Verifies that SPListItems associated with the given SPListItem as contained in the given
		/// list of association fields have values in SLAM's target data source.
		/// </summary>
		/// <param name="listItem">Source ListItem</param>
		/// <param name="associationFields">Associations to be verified in target data source</param>
		/// <param name="force">Process related ListItems whether or not they are represented in SLAM's target data source</param>
		void EnsureSlamAssociations(SPListItem listItem, List<Field> associationFields, bool force);

		/// <summary>
		/// Gets a set of field values for given list of Fields from the given SPListItem.
		/// </summary>
		/// <param name="listItem">Source ListItem</param>
		/// <param name="outputFields">List of Fields for which to get values</param>
		/// <returns>Hashtable of field names and values</returns>
		Hashtable GetFieldValues(SPListItem listItem, List<Field> outputFields);

		/// <summary>
		/// Gets the unique identifier of the given SPListItem.  The ListItem can be a new list item that has not yet been assigned an ID.
		/// </summary>
		/// <param name="listItem">Source ListItem</param>
		/// <param name="generateNewIdIfNull">Indicates whether a new ID should be generated if the given ListItem does not have a relevant ID</param>
		/// <param name="throwExceptionIfNull">Indicates whether exceptions should be thrown on error</param>
		/// <returns>Unique List Item identifier</returns>
		object GetUniqueId(SPListItem listItem, bool generateNewIdIfNull, bool throwExceptionIfNull);

		string GetSlamPropertyValue(SPListItem listItem, string name);

		void SetSlamProperty(SPListItem listItem, string name, object value);
	}
}
